﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Pager;
using X.Pager.List;
using X.Common;

namespace E.Web.Teacher.exam
{
    public partial class ScoreInput2 : TeacherBasePage
    {
        public IList<UserListModel> userList;
        public Dictionary<int, string> certificateList;
        public IList<DictAreaModel> areaList;
        public string username;
        public string email;
        public string loginid;
        public int areaid;
        public int currentCertificateID;

        protected override void ShowPage()
        {
            certificateList = GetCertificateList();
            areaList = GetTeacherAreaList(teacherid);

            string act = XRequest.GetString("act");
            username = XRequest.GetString("UserNameTxt");
            email = XRequest.GetString("EmailTxt");
            loginid = XRequest.GetString("LoginIDTxt");
            currentCertificateID = XRequest.GetInt("CertificateSlt", -1);

            if (areaList.Count == 1)
            {
                areaid = areaList[0].ID;
            }
            else
            {
                areaid = XRequest.GetInt("AreaSlt", -1);
            }

            if (act == "s")
            {
                UserBLL bll = new UserBLL();
                UserModel model = new UserModel();
                model.UserName = username;
                model.Email = email;
                model.LoginID = loginid;
                model.AreaID = areaid;
                model.IsPublicInt = 1;
                model.CurrentCertificateID = currentCertificateID;

                ListModel listModel = new ListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));
                listModel = bll.GetUserListByCondition(model, customerPageSize, pageIndex);
                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    userList = listModel.UserList;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);

                    Dictionary<string, string> parms = new Dictionary<string, string>();
                    parms.Add("act", act);
                    parms.Add("UserNameTxt", username);
                    parms.Add("LoginIDTxt", loginid);
                    parms.Add("EmailTxt", email);
                    parms.Add("AreaSlt", areaid.ToString());
                    parms.Add("CertificateSlt", currentCertificateID.ToString());
                    mypager = pager.DrawPager("selfpager", parms);
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
